package net.dipper.tankwar.game.control;

import net.dipper.tankwar.core.config.UnitItem;
import net.dipper.tankwar.core.data.ObjectMap;
import net.dipper.tankwar.core.helper.Position;

public class ShootCommand extends GameControlCommand {

	public ShootCommand(GameControl parent, ObjectMap map) {
		super(parent, map);
	}

	@Override
	public void exec() {
		Position player = map.getPlayer();		
		byte value = map.getObject(player.x, player.y);
		UnitItem item = (UnitItem) parent.getConfig().getObject(value);
		if(item == null)
			return;
		
		map.shoot(player.x, player.y, item.getAtk(), item.getRadius());
		parent.setLastOperateTimeStamp(System.currentTimeMillis());
	}

}
